package com.infosystem.demo.entities;

import com.infosystem.demo.models.RelativeDTOI;
import jakarta.persistence.*;
import java.util.UUID;

@Entity
public class Relative {
    @Id
    private String id;
    // private String employeeId;
    private String name;
    private String jobTitle;
    private String politicalTitle;
    private String type;

    @ManyToOne
    @JoinColumn(name = "employee_id", referencedColumnName = "id")
    private Employee employee;

    public Relative() {
    }

    public Relative(RelativeDTOI relativeDTOI){
        this.id = UUID.randomUUID().toString();
        //this.employeeId = relativeDTOI.getEmployeeId();
        this.name = relativeDTOI.getName();
        this.jobTitle = relativeDTOI.getJobTitle();
        this.politicalTitle = relativeDTOI.getPoliticalTitle();
        this.type = relativeDTOI.getType();
        //this.employee = null;
    }

    public Relative(String name, String jobTitle, String politicalTitle, String type) {
        this.id = UUID.randomUUID().toString();
        //this.employeeId = employeeId;
        this.name = name;
        this.jobTitle = jobTitle;
        this.politicalTitle = politicalTitle;
        this.type = type;
    }

    @PrePersist
    public void ensureId(){
        id = id == null ? UUID.randomUUID().toString() : id;
    }

    public String getId() {return id;}

    //public String getEmployeeId() {return employeeId;}
    //public void setEmployeeId(String employeeId) {this.employeeId = employeeId;}

    public String getName() {return name;}
    public void setName(String name) {this.name = name;}

    public String getJobTitle() {return jobTitle;}
    public void setJobTitle(String jobTitle) {this.jobTitle = jobTitle;}

    public String getPoliticalTitle() {return politicalTitle;}
    public void setPoliticalTitle(String politicalTitle) {this.politicalTitle = politicalTitle;}

    public String getType() {return type;}
    public void setType(String type) {this.type = type;}

    public void setEmployee(Employee employee) {this.employee = employee;}
    public Employee getEmployee() {return employee;}
}
